<script type="text/javascript">
	$(document).ready(function() {
		$(".tooltip").tooltip();
	});
	$.widget("ui.tooltip", $.ui.tooltip, {
	    options: {
	        content: function () {
	            return $(this).prop('title');
	        }
	    }
	});
</script>

<ol class="property-list receipt">
<%--	<g:hiddenField name="student" value="${fieldValue(bean: receiptInstance?.student, field: 'id')}" />--%>
<%--	<g:hiddenField name="status" value="${fieldValue(bean: receiptInstance, field: 'status')}" />--%>
<%--	<g:each in="${balancesInstance}" var="b" status="x">--%>
<%--		<g:hiddenField name="bstudent-${x}" value="${b?.student?.id}" />--%>
<%--		<g:hiddenField name="bpaydate-${x}" value="${formatDate(date:b?.paymentdate, format:'yyyy-MM-dd HH:mm:ss')}" />--%>
<%--		<g:hiddenField name="bcreadate-${x}" value="${formatDate(date:b?.creationdate, format:'yyyy-MM-dd HH:mm:ss')}" />--%>
<%--		<g:hiddenField name="bpaid-${x}" value="${b?.paid}" />--%>
<%--		<g:hiddenField name="bfee-${x}" value="${b?.fee?.id}" />--%>
<%--		<g:hiddenField name="bamount-${x}" value="${b?.amount}" />--%>
<%--		<g:hiddenField name="bdue-${x}" value="${b?.due}" />--%>
<%--	</g:each>--%>
	<li class="fieldcontain">
		<span id="total-label" class="property-label" style="text-align:left;"><g:message code="receipt.topay.label" default="Total" /></span>
		<span class="property-value" aria-labelledby="total-label"><g:fieldValue bean="${receiptInstance}" field="total"/></span>
	</li>
<%--	<g:hiddenField name="total" value="${receiptInstance?.total?.encodeAsHTML()}" />--%>
	
	<li class="fieldcontain">
		<span id="total-label" class="property-label" style="text-align:left;"><g:message code="receipt.due.label" default="Due" /></span>
		<span class="property-value" aria-labelledby="due-label"><g:fieldValue bean="${receiptInstance}" field="due"/></span>
	</li>
<%--	<g:hiddenField name="due" value="${receiptInstance?.due?.encodeAsHTML()}"/>--%>

	<li class="fieldcontain">
		<span id="creationdate-label" class="property-label" style="text-align:left;"><g:message code="receipt.creationdate.label" default="Creationdate" /></span>
		<span class="property-value" aria-labelledby="creationdate-label"><g:formatDate date="${receiptInstance?.creationdate}" /></span>
	</li>
	
<%--	<g:hiddenField name="creationdate" value="${formatDate(date:receiptInstance?.creationdate, format:'yyyy-MM-dd HH:mm:ss')}" />--%>
<%--	--%>
<%--	<g:hiddenField name="istemp" value="${receiptInstance?.istemp}"/>--%>


	<g:if test="${receiptInstance?.checks}">
	<li class="fieldcontain">
		<span id="checks-label" class="property-label"><g:message code="receipt.checks.label" default="Checks" /></span>
		
			<g:each in="${receiptInstance.checks}" var="c">
			<span class="property-value" aria-labelledby="checks-label"><g:link controller="paymentCheck" action="show" id="${c.id}">${c?.number?.encodeAsHTML()} - ${c?.bank?.encodeAsHTML()}</g:link></span>
			</g:each>
		
	</li>
	</g:if>
	
	<g:if test="${receiptInstance?.details}">
	<li class="fieldcontain">
		<table>
			<thead>
				<tr>
				<th><g:message code="receipt.items.description.label" /></th>
				<th><g:message code="receipt.items.period.label" default="Periodo"/></th>
				<th><g:message code="paymentCheck.amount.label" /> ($)</th>
				<th><g:message code="a" default="A pagar"/> ($)</th>
				</tr>
			</thead>
			<tbody>
			<g:each in="${receiptInstance.details}" status="i" var="d">
			<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
				<span class="property-value" aria-labelledby="details-label">
					<g:if test="${d?.details}">
						<td class="tooltip" title="<g:each in='${d?.details}' var='fd'><b>${fd?.name}</b>:&nbsp;$${fd?.value}<br/></g:each>" >
					</g:if>
					<g:else><td></g:else>
					${d?.description?.encodeAsHTML()}
					</td>
					<td>
					<g:if test="${ikastola.Constants.FEE_PERIOD_MONTH.equals(d?.getPeriod())}">	
						<g:formatDate format="MM-yyyy" date="${d?.getPaymentdate()}"/>
					</g:if>
					<g:else>
						<g:formatDate format="yyyy" date="${d?.getPaymentdate()}"/>
					</g:else>
					</td>
					<td>
					<g:if test="${d?.getIsdiscount() == '1'}" >
						-${d?.valueFee?.encodeAsHTML()}
					</g:if>
					<g:else>
						${d?.valueFee?.encodeAsHTML()}
					</g:else>
					</td>
					<td>
					<g:if test="${d?.getIsdiscount() == '2'}" >
						${d?.value?.encodeAsHTML()}
					</g:if>
					<g:else> - </g:else>
					</td>
				</span>
			</tr>	
<%--			<g:hiddenField name="detail-${i}" value="${d?.name?.encodeAsHTML()}#${d?.isdiscount?.encodeAsHTML()}#${d?.value?.encodeAsHTML()}#${d?.description?.encodeAsHTML()}#${d?.period?.encodeAsHTML()}#${d?.valueFee?.encodeAsHTML()}" />--%>
<%--			<g:if test="${d?.paymentdate}">--%>
<%--				<g:hiddenField name="detpdate-${i}" value="${formatDate(date:d?.paymentdate, format:'yyyy-MM-dd HH:mm:ss')}" />--%>
<%--			</g:if>--%>
			</g:each>
			</tbody>
		</table>
	</li>
	</g:if>
</ol>	
<div class="sep" style="border-bottom: 1px dashed rgb(221, 221, 221); margin: 10px 0px;"></div>

<ol class="property-list receipt">
	<g:if test="${checks}">
	<li class="fieldcontain">
		<span id="check-label" class="property-label" style="text-align:left;">Cheques:</span>
	</li>
	<li class="fieldcontain">
		<table>
			<thead>
				<tr>
				<th>N&uacute;mero</th>
				<th>Banco</th>
				<th>Nro. de cuenta</th>
				<th>Titular</th>
				<th>Monto</th>
				</tr>
			</thead>
			<tbody>
			<g:each in="${checks}" status="i" var="c">
			<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
				<span class="property-value" aria-labelledby="checks-label">
					<td>${c?.number}</td>
					<td>${c?.bank}</td>
					<td>${c?.account}</td>
					<td>${c?.owner}</td>
					<td>${c?.amount}</td>
				</span>
			</tr>	
			</g:each>
			</tbody>
		</table>
	</li>
	</g:if>	
</ol>

